package com.studerb.util;

import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author studerb test getting a database connection and then closing it gets
 *         session from HibernateUtil's sessionFactory
 */
public class CreateDataBase {

	public static void main(String[] args) {
		ClassPathXmlApplicationContext appContext;
		Logger logger = Logger.getLogger("CreateDataBase");
		logger.debug("obtaining session");
		try {
			logger.debug("Setting up Hibernate...");
			appContext = new ClassPathXmlApplicationContext("/com/studerb/util/createDbContext.xml");
			appContext.registerShutdownHook();
			logger.info("Finished successfully");
			// addServers();[
		} catch (Exception e) {
			// e.printStackTrace();
			System.err.println("error: " + e.getMessage());
			// JOptionPane.showMessageDialog(null, "Error: " +
			// ExceptionUtils.getRootCauseMessage(e));
			System.exit(1);
		}

	}
}
